ARCH_TYPE = all
INSTALL_DIR ?= usr
PACKAGES_TOP_DIR ?= ../../packages/
PACKAGES_DIR = $(PACKAGES_TOP_DIR)/$(ARCH_TYPE)

NAME = tinyos-base
VERSION = 2.1

all: package

package: 
	mkdir -p debian/DEBIAN
	cat $(NAME).control | sed 's/@version@/'$(VERSION)-`date +%Y%m%d`'/'		\
                            | sed 's/@architecture@/$(ARCH_TYPE)/'                  	\
                            > debian/DEBIAN/control;               
	cat $(NAME).changelog | sed 's/@date@/'"`date -R`"'/g'                          \
                            >> debian/DEBIAN/changelog;
#	cat $(NAME).postinst | sed 's/@install_dir@/'$(INSTALL_DIR)'/g'                 \
                            > debian/DEBIAN/postinst;
#	cp $(NAME).prerm debian/DEBIAN/prerm;
#	chmod a+rx debian/DEBIAN/postinst;
#	chmod a+rx debian/DEBIAN/prerm;
	dpkg-deb --build debian $(PACKAGES_DIR)/$(NAME)-$(VERSION).deb; 

clean:
	rm -rf debian
